﻿<%@ Page Language="C#" MasterPageFile="~/ExampleMaster.Master" AutoEventWireup="true"
    CodeBehind="TransformedSelect.aspx.cs" Inherits="Web.Samples.TransformedSelect"
    Title="Untitled Page" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleZone" runat="server">
    LINQ Transformational Select
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="IntroTextZone" runat="server">
    Since all select statements are essentially working on instances of objects we can
    modify those objects via Property Select and/or Anonymous selects to bring back
    specific data from an object set. Below we take our existing example with AddressTypes
    and return only the first letter from each entry.
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="QueryExpressZone" runat="server">
    <pre class="code">            <span style="color: rgb(0,0,255)">var</span> query = <span
        style="color: rgb(0,0,255)">from</span> o <span style="color: rgb(0,0,255)">in</span> <span
            style="color: rgb(43,145,175)">AddressType</span>.GetAddressTypes()
                        <span style="color: rgb(0,0,255)">select</span> o.Name.Substring(0, 1).ToUpper();

            <span style="color: rgb(0,0,255)">foreach</span> (<span style="color: rgb(0,0,255)">string</span> s <span
                style="color: rgb(0,0,255)">in</span> query)
                <span style="color: rgb(0,0,255)">this</span>.litQueryResults.Text += s + <span style="color: rgb(163,21,21)">"&lt;br
                    /&gt;\n"</span>;</pre>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="QueryResultsZone" runat="server">
    <asp:Literal ID="litQueryResults" runat="server" />
</asp:Content>
<asp:Content ID="Content5" ContentPlaceHolderID="ImperativeZone" runat="server">
    <pre class="code">            <span style="color: rgb(0,0,255)">var</span> query = <span
        style="color: rgb(43,145,175)">AddressType</span>.GetAddressTypes().Select(at =&gt; at.Name.Substring(0, 1).ToUpper());

            <span style="color: rgb(0,0,255)">foreach</span> (<span style="color: rgb(0,0,255)">string</span> s <span
                style="color: rgb(0,0,255)">in</span> query)
                <span style="color: rgb(0,0,255)">this</span>.litImperativeResults.Text += s + <span
                    style="color: rgb(163,21,21)">"&lt;br /&gt;\n"</span>;</pre>
</asp:Content>
<asp:Content ID="Content6" ContentPlaceHolderID="ImperativeResultsZone" runat="server">
    <asp:Literal ID="litImperativeResults" runat="server" />
</asp:Content>
